package com.mz.ozy.widget.dialog;

import android.app.Activity;
import android.content.Context;
import android.view.Gravity;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mz.ozy.R;
import com.mz.ozy.adapter.TrainPlanAdapter;

import java.util.List;

public class FitnessPlanDialog extends BaseDialog implements View.OnClickListener {

    private List<String> xlList1;

    private RecyclerView mRecyclerView;
    private TrainPlanAdapter mPlanAdapter;

    public FitnessPlanDialog(Activity mContext, List<String> coinsList) {
        super(mContext, R.layout.dialog_fitness_plan, Gravity.BOTTOM, true, true);
        xlList1 = coinsList;
        initView();
    }

    private void initView() {
        mRecyclerView = getView(R.id.recyclerView);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        mPlanAdapter = new TrainPlanAdapter(xlList1);
        mRecyclerView.setAdapter(mPlanAdapter);

        mPlanAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                mPlanAdapter.clickSelectView(view, position);
                if (mListener != null) {
                    mListener.onConfirm(position);
                }
            }
        });
    }

    public void setPicker(List<String> coinsList) {
        xlList1 = coinsList;
    }

    @Override
    public void onClick(View v) {
        toggleDialog();
    }

    private onDialogListener mListener;

    public void setOnDialogListener(onDialogListener listener) {
        mListener = listener;
    }


    public interface onDialogListener {
        void onConfirm(int pos);
    }
}
